﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IWS.SiteManager.Core.Model
{
	public class SetupInformation
	{
		public string DBType { get; set; }
		public string DBHost { get; set; }
		public string DBName { get; set; }
		public string DBUser { get; set; }
		public string DBPass { get; set; }
		public bool DBIntegrated { get; set; }
		public bool MDBDifferent { get; set; }
		public string MDBHost { get; set; }
		public string MDBName { get; set; }
		public string MDBUser { get; set; }
		public string MDBPass { get; set; }
		public bool MDBIntegrated { get; set; }
		public string AdminUser { get; set; }
		public string AdminPass { get; set; }
		public string AdminEmail { get; set; }
		public string WebHost { get; set; }


		public string DBConnectionString
		{
			get
			{
				StringBuilder builder = new StringBuilder();
				builder.AppendFormat("Data Source={0};Initial Catalog={1};", this.DBHost, this.DBName);

				if (this.DBIntegrated)
					builder.AppendFormat("Integrated Security=true;");
				else
					builder.AppendFormat("User ID={0};Password={1};", this.DBUser, this.DBPass);

				return builder.ToString();
			}
		}

		public string MembershipDBConnectionString
		{
			get
			{
				if (this.MDBDifferent)
				{
					StringBuilder builder = new StringBuilder();
					builder.AppendFormat("Data Source={0};Initial Catalog={1};", this.MDBHost, this.MDBName);

					if (this.MDBIntegrated)
						builder.AppendFormat("Integrated Security=true;");
					else
						builder.AppendFormat("User ID={0};Password={1};", this.MDBUser, this.MDBPass);

					return builder.ToString();
				}

				return this.DBConnectionString;
			}
		}
	}
}
